package com.platform.module.common.base;

import com.platform.module.common.enums.app.AppNameEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

/**
 * @author Long
 **/
@Slf4j
@Data
@ToString
@EqualsAndHashCode
public class App {

    private AppNameEnum appName;
    private String appVersion;
    private String appHotVersion;
    private String appMuId;
    private String phoneModel;
    private String ip;
    private String ipv6;
    private String netType;
    private String areaCode;
    private String source;
    private String agent;
    private String inviteCode;
    private String imei;
    private String signMD5;
    private String curTime;
    private String oaid;
    private String androidId;
    private String appsFlyerUID;
    private String emulator;
    private Boolean isRooted;
    private String uuid;
    private String deviceId;
    private String params;
    private String gpParams;
    private String deviceJson;
    private String referer;
    private boolean review;
    private String newImei;
    private String newImsi;
    private String newMac;
    private String newGps;

    public static App parseSafe(String appName, String source) {
        AppNameEnum appNameEnum = AppNameEnum.valueOf(appName);
        App result = new App();
        result.appName = appNameEnum;
        result.source = source;
        return result;
    }

    public static App parseSafe(String appName, String appVersion, String appHotVersion, String signMD5, String curTime,
                                String appMuId, String phoneModel, String areaCode, String source,
                                String agent, String inviteCode, String ip, String ipv6, String imei,
                                String oaid, String androidId, String appsFlyerUID, String emulator,
                                boolean isRooted, String uuid, String deviceId, String params,
                                String gpParams, String deviceJson, String referer, String newImei,
                                String newImsi, String newMac, String newGps) {
        App result = new App();

        try {
            result.appName = AppNameEnum.valueOfAppName(appName);
        } catch (Exception var31) {
            log.error("异常信息appName=" + appName, var31);
        }

        result.appVersion = appVersion;
        result.appHotVersion = appHotVersion;
        result.signMD5 = signMD5;
        result.curTime = curTime;
        result.appMuId = appMuId;
        result.phoneModel = phoneModel;
        result.areaCode = areaCode;
        result.source = source;
        result.agent = agent;
        result.inviteCode = inviteCode;
        result.ip = ip;
        result.ipv6 = ipv6;
        result.imei = imei;
        result.oaid = oaid;
        result.androidId = androidId;
        result.appsFlyerUID = appsFlyerUID;
        result.emulator = emulator;
        result.isRooted = isRooted;
        result.uuid = uuid;
        result.deviceId = deviceId;
        result.params = params;
        result.gpParams = gpParams;
        result.deviceJson = deviceJson;
        result.referer = referer;
        result.newImei = newImei;
        result.newImsi = newImsi;
        result.newMac = newMac;
        result.newGps = newGps;
        return result;
    }

    public App() {
        this.appName = AppNameEnum.NONE;
        this.agent = "normal";
    }


}
